package com.nageoffer.shortlink.admin.toolkit;

import java.util.Random;

public final class RandomGenerator {
    private static final String ALL_CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final int RANDOM_LENGTH = 6;
    private static Random random = new Random();

    /**
     * 生成包含数字和英文字母的指定长度的随机字符串
     *
     * @return 生成的随机字符串
     */
    public static String generateRandom() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < RANDOM_LENGTH; i++) {
            int index = random.nextInt(ALL_CHARACTERS.length());
            sb.append(ALL_CHARACTERS.charAt(index));
        }
        return sb.toString();
    }


}
